/**
 * Created by dukes on 2016/3/2.
 */
class GuildMedalPanel extends eui.Component {
    public constructor() {
        super();
        this.skinName = "skins.scene.GuildMedalSkin";
        // this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAdded, this );
        // this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.onRemoved, this);
    }

    // public onReturn(evt:egret.TouchEvent){
    //     SceneMgr.getInstance().switchScene(SceneMgr.SCENE_GUILD_LIST);
    // }

    // public onClean(evt:egret.TouchEvent){
    //     MedalCleanPanel.getInstance().show();
    // }

    // public onInject(evt:egret.TouchEvent){
    //     if( Model.userExt.transfuseTimes < Model.userExt.maxTransfuseTimes)
    //         window["__injectMedal"]();
    //     else
    //         RemindPanel.getInstance().showContent("您是否花费25钻石购买额外的5次注入次数",this, this.onBuy);
    // }

    // public onBuy(){
    //     if( Model.me.diamond < 25){
    //         BuyDiamondPanel.getInstance().show();
    //     }else{
    //         window["__resetCleanTime"]();
    //     }
    // }

    // public onUpgrade(evt:egret.TouchEvent){
    //     var config = GuildMgr.getInstance().logoConfig[GuildMgr.getInstance().guildLogo.level];
    //     if( GuildMgr.getInstance().myMemberInfo.contribution < config.unlockContribution){
    //         ShowHint("升级所需的贡献值不足");
    //     }else{
    //         window["__upgradeMedal"]();
    //     }

    // }

    // private onAdded(evt:egret.Event){
    //     this.img_upgrade.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onUpgrade, this );
    //     this.img_clean.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClean, this );
    //     this.img_return.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onReturn, this );
    //     this.img_inject.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onInject, this );
    //     this.updateDisplay();
    // }
    // private onRemoved(evt:egret.Event){
    //     this.img_upgrade.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onUpgrade, this );
    //     this.img_return.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onReturn, this );
    //     this.img_clean.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onClean, this );
    //     this.img_inject.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onInject, this );
    // }
    // public updateDisplay(){
    //     var logo = GuildMgr.getInstance().guildLogo;
    //     if( logo){
    //         this.img_medal.source = GameConst.Res_Root+"resource/assets/medals/"+logo.logoId+".png";
    //         this.lab_level.text = "LV."+logo.level;
    //         this.lab_pro.text = logo.contribution+"/"+logo.levelContribution;
    //         this.lab_cur_prop.text = "当前属性：\r攻击："+(logo.attrAttack+logo.addtionAttack)+"\r防御："+(logo.attrDefense+logo.addtionDefense);
    //         this.lab_next_prop.text = "下级属性：\r攻击："+(logo.nextAttrAttack+logo.addtionAttack)+"\r防御："+(logo.nextAttrDefense+logo.addtionDefense);
    //         this.img_pro.width =  logo.contribution*138/logo.levelContribution;

    //         this.img_upgrade.visible = logo.contribution == logo.levelContribution;
    //         this.img_inject.visible = logo.contribution != logo.levelContribution;
    //     }
    //     if(  logo.contribution == logo.levelContribution ){
    //         var config = GuildMgr.getInstance().logoConfig[GuildMgr.getInstance().guildLogo.level];
    //         var msg:string = "升级消耗：\r贡献*"+config.unlockContribution;
    //         var goodInfo:GoodInfo;
    //         for(var key in config.props){
    //             goodInfo = Model.GetGoodInfoById(parseInt(key));
    //             msg+="\r"+goodInfo.name+"*"+config.props[key];
    //         }
    //         this.lab_cost.text = msg;
    //     }else{
    //         this.lab_cost.text = "每次注入消耗贡献："+logo.perContribution;
    //         this.inject_time.text = Model.userExt.transfuseTimes+"p"+Model.userExt.maxTransfuseTimes;
    //     }
    //     this.lab_has.text = "总贡献："+GetNumString(GuildMgr.getInstance().myMemberInfo.contribution,false,true);
    // }
    // public lab_level:eui.Label;
    // private img_pro:eui.Image;
    // private img_return:eui.Image;
    // private lab_pro:eui.Label;
    // public lab_cur_prop:eui.Label;
    // private lab_next_prop:eui.Label;
    // private lab_cost:eui.Label;
    // private lab_has:eui.Label;
    // private img_medal:eui.Image;
    // private img_inject:eui.Image;
    // private img_clean:eui.Image;
    // private img_upgrade:eui.Image;
    // private inject_time:eui.BitmapLabel;
    // public partAdded(name:string, instance:any) {
    //     super.partAdded(name, instance);
    //     if (name == "lab_level") {
    //         this.lab_level = instance;
    //     } else if (name == "img_pro") {
    //         this.img_pro = instance;
    //     }else if (name == "lab_pro") {
    //         this.lab_pro = instance;
    //     }else if (name == "lab_cur_prop") {
    //         this.lab_cur_prop = instance;
    //     }else if (name == "lab_next_prop") {
    //         this.lab_next_prop = instance;
    //     }else if (name == "lab_cost") {
    //         this.lab_cost = instance;
    //     }else if (name == "lab_has") {
    //         this.lab_has = instance;
    //     }else if (name == "img_medal") {
    //         this.img_medal = instance;
    //     }else if (name == "img_inject") {
    //         this.img_inject = instance;
    //     }else if (name == "img_clean") {
    //         this.img_clean = instance;
    //     }else if (name == "inject_time") {
    //         this.inject_time = instance;
    //     }else if (name == "img_return") {
    //         this.img_return = instance;
    //     }else if (name == "img_upgrade") {
    //         this.img_upgrade = instance;
    //     }
    // }
    private static _instance:GuildMedalPanel;
    public static getInstance():GuildMedalPanel{
        if( GuildMedalPanel._instance == null)
            GuildMedalPanel._instance = new GuildMedalPanel();
        return GuildMedalPanel._instance;
    }
}